package com.axjy.action;

import com.axjy.pojo.Role;
import com.axjy.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by l on 2018/1/4.
 */
@Controller
@RequestMapping("/role")
public class RoleHandler {

    @Resource
    private RoleService roleService;

    @GetMapping("/list")
    public String list(Model model){
        List<Role> list =roleService.getAll();
        model.addAttribute("list",list);
        return "role/search";
    }

    @GetMapping("/addRole")
        public String addRole(Role role){
            String isOk="1";
            try{
                roleService.addRole(role);
            }catch (Exception ex){
                isOk="0";
            }
            return isOk;
    }
}
